#!/bin/bash
@Autor: itdby

# Detect OS
OS="$(uname -s)"

install_mkcert() {
    # Install mkcert
    echo "Installing mkcert..."
    if [ "$OS" == "Darwin" ]; then
        # macOS
        brew install mkcert
        brew install nss # if you use Firefox
    elif [ "$OS" == "Linux" ]; then
        # Linux
        if command -v apt-get >/dev/null; then
            sudo apt-get install -y libnss3-tools
        elif command -v yum >/dev/null; then
            sudo yum install -y nss-tools
        elif command -v dnf >/dev/null; then
            sudo dnf install -y nss-tools
        fi
        curl -JLO "https://dl.filippo.io/mkcert/latest?for=linux/amd64"
        chmod +x mkcert-v*-linux-amd64
        sudo mv mkcert-v*-linux-amd64 /usr/local/bin/mkcert
    else
        echo "Unsupported OS"
        exit 1
    fi
    mkcert -install
}

install_mkcert
